
using FancyScrollView;
using GameLogic;
using System.Runtime.Remoting.Contexts;
using UnityEngine;

public class LoopScrollViewItemView : FancyScrollRectCell<LoopScrollViewItemData, LoopScrollViewItemContext>
{
    public override void Initialize()
    {
        var button = GetComponent<ButtonEx>();
        if (button)
            button.AddClickEvent(() => Context.OnCellClicked?.Invoke(Index));
    }

    public override void UpdateContent(LoopScrollViewItemData itemData)
    {
        var selected = Context.SelectedIndex == Index;
    }
    protected override void UpdatePosition(float normalizedPosition, float localPosition)
    {
        base.UpdatePosition(normalizedPosition, localPosition);

        var selected = Context.SelectedIndex == Index;
        transform.localScale =  Vector3.one * (selected ? 1.2f : 1);
        transform.localPosition +=  Vector3.up * (selected ? 20 : 0);
    }
}